package com.cby.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/home")
public class HomeController {

    @RequestMapping("/test")
    public String say(HttpServletRequest request){
        System.out.println("test....");
        request.setAttribute("name","Jason"); // 指定Model的值
        //return "/index.jsp";
        return "/demo";
    }

    @RequestMapping("/login")
    public ModelAndView login(HttpServletRequest request) {
        String userName = request.getParameter("userName");
        String password = request.getParameter("password");

        ModelAndView mav = new ModelAndView("/home");
        mav.addObject("name", userName);
        return mav;
    }
}
